<?php

/**
 * language actions.
 *
 * @package    toolbase
 * @subpackage language
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class languageActions extends sfActions
{
  public function executeChangeLanguage(sfWebRequest $request)
  {
    $form = new LanguageForm(
      $this->getUser(),
      array('languages' => Toolbase::getPossibleLanguages() )
    );
 
    $form->process($request);
        
        $query = parse_url( $request->getReferer() );
        
        $output = array();
        if( isset( $query['query'] ) ) {
                parse_str($query['query'], $output);
        }
        $output['uselang'] = $request->getParameter('language');
        
        $url = sprintf( '%s://%s%s?%s', $query['scheme'], $query['host'], $query['path'], http_build_query( $output ) );
        
        $this->redirect($url);
  }

}
